package com.witmore.neutron.ai.web.enums;

import lombok.Getter;

/**
 * Description: PublishTypeEnum
 * Author: 豆子高
 * Date: 2025/6/6 12:26
 */

@Getter
public enum PublishTypeEnum {
    WEB(0, "web", "/chat/"),
    API(1, "api", "/v1/api/chat/completions?code=");

    private final Integer code;
    private final String desc;
    private final String urlPrefix;

    PublishTypeEnum(Integer code, String desc, String urlPrefix) {
        this.code = code;
        this.desc = desc;
        this.urlPrefix = urlPrefix;
    }

    public static PublishTypeEnum fromCode(Integer code) {
        for (PublishTypeEnum type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Invalid PublishTypeEnum code: " + code);
    }
}
